<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<title>手机商城</title>
<!-- CSS -->
<!--<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">-->
<link rel="stylesheet" href="{url:#css/materialize.min.css}" />
<link rel="stylesheet" href="{url:#css/me.css}" />
<link rel="stylesheet" href="{url:#css/iconfont.css}" />
<style type="text/css">
body{
	background:#FFFFFF;
}
a{
	color:black;
}
</style>

<!-- JS -->
<script src="{url:#js/jquery-1.11.3.min.js}"></script>
<script src="{url:#js/materialize.min.js}"></script>
<script src="{url:#js/yang_check.js}"></script>
</head>
<body>
<!-- TitleBar 开始 -->
<div class="navbar-fixed">
  <nav>
    <div class="nav-wrapper red accent-4 valign-wrapper">
      <ul class="left">
        <li><a href="{url:/mobile/user_center}"><i class="iconfont">&#xe63c;</i></a></li>
      </ul>
      <span class="title-bar-size center_align">我的收货地址</span>
      <ul class="right">
        <li><a href="{url:/mobile/my_addr_edit/is_choose_addr/1}"><i class="iconfont">&#xe669;</i></a></li>
      </ul>
    </div>
  </nav>
</div>
<!-- TitleBar 结束 -->
<!-- 收货地址列表 开始 -->
<div class="addr-list">
	<ul>
		{set:$user=$_SESSION['mobile_user']}
		{set:$user_id = $user['id']}
		{query:name=address where=user_id eq $user_id}
		<li>
			{set:$is_choose_addr = $_SESSION['is_choose_addr']}
			{if:$is_choose_addr == 1}
				{set:$rev_url = Url::getRefRoute()}
				{set:$json_str = $_SESSION['json_str']}
				<div class="addr-item" onclick="tz({$item[id]})">
			{else:}
				<div class="addr-item">
			{/if}
			
				<span class="addr-name">{$item['accept_name']}</span>
				<span class="addr-tel">{$item['mobile']}</span>
				<p style="font-size:1.2em;">{echo:Zyk_tj::zyk_info('area',$item['province'],'name')}
											{echo:Zyk_tj::zyk_info('area',$item['city'],'name')}
											{echo:Zyk_tj::zyk_info('area',$item['county'],'name')}{$item['addr']}</p>
				<div class="deshed-divider"></div>
				<div style="float:left;margin-top:3px;">

					{if:$item['is_default']==1}
						<a><i class="iconfont" style="font-size:1.2em; color:red; margin:3px;">&#xe66d;</i> 默认地址</a>
					{else:}
						<a href="javascript:;" onclick="set_default_addr({$item[id]})"><i class="iconfont" style="font-size:1.2em; margin:3px;">&#xe67a;</i> 默认地址</a>
					{/if}
					
				</div>
				<div style="float:right">
					{if:!empty($_SESSION['is_choose_addr'])}
						<a style="margin-right:20px;" href="{url:/mobile/my_addr_edit/id/$item[id]/is_choose_addr/1}">
					{else:}
						<a style="margin-right:20px;" href="{url:/mobile/my_addr_edit/id/$item[id]}">
					{/if}
					<i class="iconfont" style="font-size:1.5em;margin:3px;">&#xe67c;</i>
					编辑</a>
					<a href="{url:/mobile/del_addr/id/$item[id]}" onclick="return confirm('确定要执行此操作吗?');">
					<i class="iconfont" style="font-size:1.5em;margin:3px;">&#xe672;</i>
					删除</a>
				</div>
				<div class="clearfix"></div>
			</div>
		</li>
		<li>
			<div class="divider"></div>
		</li>
		{/query}
		
		<!-- 
		<li>
			<div class="addr-item">
				<span class="addr-name">王小明</span>
				<span class="addr-tel">13698744562</span>
				<p style="font-size:1.2em;">北京市东城区两道拐大街幸福小区9号楼3单元5644</p>
				<div class="deshed-divider"></div>
				<div style="float:left;margin-top:3px;">
					<a>
					<i class="iconfont" style="font-size:1.2em; margin:3px;">&#xe67a;</i>
					设为默认地址</a>
				</div>
				<div style="float:right">
					<a style="margin-right:20px;">
					<i class="iconfont" style="font-size:1.5em;margin:3px;">&#xe67c;</i>
					编辑</a>
					<a>
					<i class="iconfont" style="font-size:1.5em;margin:3px;">&#xe672;</i>
					删除</a>
				</div>
				<div class="clearfix"></div>
			</div>
		</li>
		<li><div class="divider"></div></li>
		<li>
			<div class="addr-item">
				<span class="addr-name">王小明</span>
				<span class="addr-tel">13698744562</span>
				<p style="font-size:1.2em;">北京市东城区两道拐大街幸福小区9号楼3单元5644</p>
				<div class="deshed-divider"></div>
				<div style="float:left;margin-top:3px;">
					<a>
					<i class="iconfont" style="font-size:1.2em; margin:3px;">&#xe67a;</i>
					设为默认地址</a>
				</div>
				<div style="float:right">
					<a style="margin-right:20px;">
					<i class="iconfont" style="font-size:1.5em;margin:3px;">&#xe67c;</i>
					编辑</a>
					<a>
					<i class="iconfont" style="font-size:1.5em;margin:3px;">&#xe672;</i>
					删除</a>
				</div>
				<div class="clearfix"></div>
			</div>
		</li>
		<li>
			<div class="divider"></div>
		</li>
		-->
	</ul>
</div>
<!-- 收货地址列表 结束 -->

<script type="text/javascript">
function tz( addr_id )
{
	document.location.href="{url:/mobile/sub_order}&json_str={$json_str}&addr_id="+addr_id;
}
function set_default_addr(id)
{
	
	$.post("{url:/mobile/set_default_addr}",{id:id},function(data){
		if(data['status']=='success')
	    {
			window.location.replace("{url:/mobile/user_center}");
		    //alert(data['msg']);
		    //个人中心页面
            document.location.href="{url:/mobile/my_addr}";
        }
        else
	    {
            yang_alert(data['msg']);
            window.location.replace("{url:/mobile/user_center}");
            //show_msg(data['msg']);
            document.location.href="{url:/mobile/my_addr}";
        }
    },'json');
}
</script>

</body>
</html>
